/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.modules;

/**
 *
 * @author geniuz
 */
public class AlgoUtil {
    public AlgoUtil()
    {
    }

    public static final int getTag(int ai[], int i)
    {
        _tagIteration = 0;
        int j = ai[i];
        int k = (j >> 5) << 5;
        if(j - k == 31)
        {
            int l;
            for(j = 0; k != 0; j += l - k)
            {
                _tagIteration++;
                l = ai[i + _tagIteration];
                k = (l >> 7) << 7;
                j <<= 7;
            }

        }
        return j;
    }

    public static final int getLength(int ai[], int i)
    {
        return ai[i];
    }

    public static final boolean isLastTagsZero(int ai[], int i)
    {
        boolean flag = true;
        int j = 0;
        do
        {
            if(j >= 4)
                break;
            i += j;
            if(i < ai.length && ai[i] != 0)
            {
                flag = false;
                break;
            }
            j++;
        } while(true);
        return flag;
    }

    public static final int getTagIteration()
    {
        return _tagIteration;
    }

    private static int _tagIteration;

}
